﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BUS;
using DAO;

public partial class UControl_UC_BlockLeft_Category : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BUS_WRCATEGORY _buswrcategory = new BUS_WRCATEGORY();
        BUS_WRCATEGORYLV1 _buswrcategorylv1 = new BUS_WRCATEGORYLV1();

        if (!IsPostBack)
        {
            foreach (WRCATEGORY _wrcategory in _buswrcategory._GetList(p => p.IDLang == 1))
            {
                string CategoryName = _wrcategory.CategoryName + " (" + _buswrcategorylv1._GetList(p => p.IDCategory == _wrcategory.ID).ToList().Count + ")";
                TreeNode _tnCategory = new TreeNode(CategoryName, _wrcategory.ID.ToString());

                foreach (WRCATEGORYLV1 _wrcategorylv1 in _buswrcategorylv1._GetList(p => p.IDCategory == _wrcategory.ID))
                {
                    TreeNode _tnCategorylv1 = new TreeNode(_wrcategorylv1.CategoryLv1Name, _wrcategorylv1.ID.ToString());
                    _tnCategory.ChildNodes.Add(_tnCategorylv1);
                }

                trvCategory.Nodes.Add(_tnCategory);
                trvCategory.CollapseAll();
            }
        }
    }
}